/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-08-15
 * Time: 21:33
 */
public class Solution4 {
    public static void main(String[] args) {
        int[] array = new int[]{1, 2, 3, 4};
        int len = array.length;
        int s = arraySum(array, len);
        System.out.println(s);
    }

    public static int arraySum(int[] array, int len) {
        if (len == 1) {
            return array[0];
        } else {
            return array[len - 1] + arraySum(array, len - 1);
        }
    }
}
